home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-12-27 | 1.9 KB | 75 lines | [TEXT/CWIE] |
- //
- // CQD3DGimbalPane.cp
- //
- // class CQD3DGimbalPane
- // A class for displaying a QuickDraw 3D view where
- // dragging in the scene moves the camera around such
- // that up is always up (+z direction).
- //
- // by James Jennings
- // Started November 24, 1995
- //
-
- #include "CQD3DGimbalPane.h"
- #include "CCameraMover.h"
- #include "StQ3Disposer.h"
- #include "QD3D Debug Macros.h"
-
- CQD3DGimbalPane::CQD3DGimbalPane()
- { // default constructor
- // Does nothing. Must call FinishCreate() later.
- }
-
- CQD3DGimbalPane::CQD3DGimbalPane(const CQD3DGimbalPane &inOriginal)
- : CQD3DPane(inOriginal)
- { // copy constructor
- }
-
- CQD3DGimbalPane::CQD3DGimbalPane(LStream *inStream)
- : CQD3DPane(inStream)
- { // stream constructor
- // Does nothing. Must call FinishCreate() later.
- }
-
- CQD3DGimbalPane::~CQD3DGimbalPane()
- {
- }
-
- void
- CQD3DGimbalPane::ClickSelf( const SMouseDownEvent& inMouseDown)
- { // the method that does the "gimballing"
- FocusDraw();
- Point oldMouse, newMouse;
- oldMouse = newMouse = inMouseDown.whereLocal;
-
- CCameraMover cameraMover(mView);
-
- while (StillDown()) {
- oldMouse = newMouse;
- ::GetMouse(&newMouse);
- if ( !::EqualPt(oldMouse, newMouse)) {
- // convert change in mouse into a change in camera position
- // (quick and dirty for now: do careful math later)
- cameraMover.Move( (oldMouse.h - newMouse.h) * kQ3Pi/200,
- (oldMouse.v - newMouse.v) * kQ3Pi/200 );
- // Allow sub-classes to have their say
- ClickLoop(inMouseDown.macEvent);
- // Update the scene
- DrawSelf();
- } else { // mouse didn't move
- // Allow sub-classes to have their say
- if (ClickLoop(inMouseDown.macEvent))
- // Update the scene IF the sub-class says so.
- DrawSelf();
- }
- }
- }
-
- Boolean
- CQD3DGimbalPane::ClickLoop(const EventRecord &/*inMacEvent*/)
- { // Subclasses may override to modify the scene in some other way.
- // Return true if you want to redraw the scene (because you're
- // animating something for example.)
- return false;
- }
-